using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace DarkLordsApprenticeV2
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Display : DrawableGameComponent
    {
        public Display(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }

        Texture2D back;
        Texture2D bar;
        Texture2D[] eyes = new Texture2D[3];
        Texture2D eye;
        Texture2D front;

        SpriteFont font1;
        SpriteFont font2;

        SpriteBatch spriteBatch;

        int currentMagic;
        int maxMagic;
        int evilnessLevel;
        float barOffset;

        enum State { Green, Blue, Black };


        protected override void LoadContent()
        {
            back = Game.Content.Load<Texture2D>("InterfaceBottom");
            bar = Game.Content.Load<Texture2D>("MagicBar");
            eyes[0] = Game.Content.Load<Texture2D>("EvilEyeGreen");
            eyes[1] = Game.Content.Load<Texture2D>("EvilEyeBlue");
            eyes[2] = Game.Content.Load<Texture2D>("EvilEyeRed");
            eye = eyes[0];
            front = Game.Content.Load<Texture2D>("InterfaceTop");

<<<<<<< .mine
            font1 = Game.Content.Load<SpriteFont>("Verdana");
            font2 = Game.Content.Load<SpriteFont>("Cambria");

=======
            font1 = Game.Content.Load<SpriteFont>("font");
            font2 = Game.Content.Load<SpriteFont>("Cambria");

>>>>>>> .r34
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            currentMagic = 1;
            maxMagic = 1;
            evilnessLevel = 1;
            barOffset = 0;
        }


        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(back, new Vector2(0, 0), null, Color.White, 0, new Vector2(0,0), .6f, SpriteEffects.None,0);
            spriteBatch.Draw(bar, new Vector2(0, 0), null, Color.White, 0, new Vector2(0, barOffset), .6f, SpriteEffects.None, 0);
            spriteBatch.Draw(eye, new Vector2(0, 0), null, Color.White, 0, new Vector2(0, 0), .6f, SpriteEffects.None, 0);
            spriteBatch.Draw(front, new Vector2(0, 0), null, Color.White, 0, new Vector2(0, 0), .6f, SpriteEffects.None, 0);
            spriteBatch.DrawString(font1, "Evilness Lv. " + evilnessLevel, new Vector2(66, 2), Color.BlanchedAlmond,0,new Vector2(0,0),.8f,SpriteEffects.None,0);
            spriteBatch.DrawString(font1, currentMagic + "/" + maxMagic + "MP", new Vector2(68, 20), Color.BlanchedAlmond, 0, new Vector2(0, 0), .8f, SpriteEffects.None, 0);
            spriteBatch.End();
        }

        public void UpdateDisplay(int curMagic, int mxMagic, int evilness)
        {
            currentMagic = curMagic;
            maxMagic = mxMagic;
            evilnessLevel = evilness;
            barOffset = 500.0f * (1.0f - (float)curMagic / (float)mxMagic);
        }
    }
}
